package com.indeep.user.emun;

import lombok.AllArgsConstructor;

import java.util.Objects;

/**
 * 身份 0——用户 1——VIP 2——KOL
 */
@AllArgsConstructor
public enum AppUserIdentity {

    NORMAL(0, "普通用户"),
    KOL(1, "Kol用户"),
    VIP(2, "Vip用户");

    public final Integer index;
    public final String str;


    // 通过ID获取枚举值
    public static AppUserIdentity getByIndex(Integer index) {
        if (index == null) {
            return null;
        }
        for (AppUserIdentity i : values()) {
            if (Objects.equals(i.index, index)) {
                return i;
            }
        }
        return null;
    }

    // 通过str获取枚举值
    public static AppUserIdentity getByStr(String str) {
        if (str == null) {
            return null;
        }
        for (AppUserIdentity i : values()) {
            if (Objects.equals(i.str, str)) {
                return i;
            }
        }
        return null;
    }
}
